package 杨佳佳.第四章作业;

import java.util.Scanner;

//用户输入整数n，计算1!+(1!+2!)+(1!+2!+3!)+…..+(1!+2!+…n!)
//        用方法实现
//        有参数有返回值
public class K {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入整数n: ");
            int n = scanner.nextInt();
            System.out.println(jc(n));
        }
        public static int jc(int n) {
            int sum=1;
            if (n<0){
                System.out.println("输入错误");
            }else if (n==0||n==1){
                System.out.println(n+"的阶层为1");
            }else {
                for (int i = 1; i <=n ; i++) {
                    sum*=i;
                }
                return sum;
            }
            return sum;
        }
    }

